<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="jxl.*" %>
<%@ page import="jxl.write.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>信息修改</title>
</head>
<body>
<%
	request.setCharacterEncoding("UTF-8");
	//传递各项数据 
	String stuid = request.getParameter("stid").trim();
	String stuId = request.getParameter("stuId").trim();
	String stuName = request.getParameter("stuName").trim();
	String birth = request.getParameter("birth").trim();
	String stuTele = request.getParameter("stuTele").trim();
	String stuQQ = request.getParameter("stuQQ").trim();
	Calendar cal = Calendar.getInstance();			/*用Calendar函数获取一个实例*/
	cal.set(Integer.parseInt(birth.split("/")[0]),Integer.parseInt(birth.split("/")[1])-1,Integer.parseInt(birth.split("/")[2]));
	Date date = cal.getTime();								/*取得当前时间*/
	SimpleDateFormat datef = new SimpleDateFormat("yyyy年MM月dd日");	 /*新建一个对象，并 设定格式*/
	birth = datef.format(date).toString();			 /*将date转化为字符串类型*/
	File fileName = new File("D:/workplace/stuinfo.xls");
	Workbook book = Workbook.getWorkbook(fileName);			 /*新建一个book对象*/
	Sheet sheet1 = book.getSheet(0);
	WritableWorkbook workbook = Workbook.createWorkbook(new File("D:/workplace/stuinfo.xls"),book);		/*新建一个workbook对象，指向book */
	WritableSheet sheet2 = workbook.getSheet(0);		 	/*得到第一张工作表*/
	int rows = sheet1.getRows();			/*取得总行数*/
	for(int i= rows-1; i>0; i--)
	{
		Cell cel = sheet1.getCell(0, i);
		String str = cel.getContents();
		if(str.equals(stuid))
		{
			WritableCell cell1 = sheet2.getWritableCell(0, i);
			if (cell1.getType() == CellType.LABEL)
			{
			Label l1 = (Label) cell1;
			l1.setString(stuId);
			}
			
			WritableCell cell2 = sheet2.getWritableCell(1, i);
			if (cell2.getType() == CellType.LABEL)
			{
			Label l2 = (Label) cell2;
			l2.setString(stuName);
			}
			
			WritableCell cell3 = sheet2.getWritableCell(2, i);
			if (cell3.getType() == CellType.LABEL)
			{
			Label l3 = (Label) cell3;
			l3.setString(birth);
			}
			
			WritableCell cell4 = sheet2.getWritableCell(3, i);
			if (cell4.getType() == CellType.LABEL)
			{
			Label l4 = (Label) cell4;
			l4.setString(stuTele);
			}
			
			WritableCell cell5 = sheet2.getWritableCell(4, i);
			if (cell5.getType() == CellType.LABEL)
			{
			Label l5 = (Label) cell5;
			l5.setString(stuQQ);
			}
						
		}				
	}
	workbook.write();
	workbook.close();
	book.close();
	%>
	
	<div>修改成功，请点击<a href="managermodifyinfos.jsp?stuid=<%= stuId%>">返回</a></div>	
		
</body>
</html>